{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>添加/编辑</h5>
                </div>
                <div class="ibox-content">

					<form id="formEdit" method="post" class="form-horizontal" action="{:url('edit')}">

	
						<div class="form-group">
							<label class="col-sm-3 control-label"><span style="color:red;">*&nbsp;</span>名称</label>
							<div class="input-group col-sm-4">
								<input type="text" name="title" placeholder="请输入" autocomplete="off" class="form-control"
									   value="{:isset($list.title)?$list.title:''}" >
							</div>
						</div>

						<div class="form-group">
							<label class="col-sm-3 control-label"><span style="color:red;"></span>排序</label>
							<div class="input-group col-sm-4">
								<input type="text" name="sort" placeholder="请输入"  value="{:isset($list.sort)?$list.sort:''}"  autocomplete="off" class="form-control">
							</div>
						</div>
						
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-3">
								<input type="hidden" name="id" value="{:isset($list['id'])?$list['id']:''}">
                                <button class="btn btn-primary" type="submit"><i class="fa fa-save"></i> 保存</button>&nbsp;&nbsp;&nbsp;
                                <a class="btn btn-danger" href="javascript:history.go(-1);"><i class="fa fa-close"></i> 返回</a>
                            </div>
                        </div>
					</form>

                </div>
            </div>

        </div>
    </div>
</div>
{include file="public/footer" /}
<script type="text/javascript">
    //提交
    $(function(){
        $('#formEdit').ajaxForm({
            beforeSubmit: checkForm, 
            success: complete, 
            dataType: 'json'
        });
        
        function checkForm(){
            if( '' == $.trim($('input[name="title"]').val())){
                layer.msg('请输入名称',{icon:2,time:1500,shade: 0.1}, function(index){
                layer.close(index);
                });
                return false;
            }
        }


        function complete(data){
            if(data.code==1){
                layer.msg(data.msg, {icon: 6,time:1500,shade: 0.1}, function(index){
                    window.location.href="{:url('course_grade/index')}";
                });
            }else{
                layer.msg(data.msg, {icon: 5,time:1500,shade: 0.1});
                return false;   
            }
        }
     
    });

</script>
</body>
</html>